﻿@inherits EditOperationDialogBase<SysJobTriggerDto, int, EasyJobLocalResource>
@if (_editModel != null)
{
    <Form Loading="@_dialogLoading.Value"
          Model="@_editModel"
          LabelCol="new ColLayoutParam { Span = 8 }"
          WrapperCol="new ColLayoutParam { Span = 16 }"
          OnFinish="OnFormFinish"
          Context="model"
          Size="@AntSizeLDSType.Small">
        <Tabs DefaultActiveKey="1" Type="@TabType.Line" @bind-ActiveKey="tabActiveKey">
            <TabPane Key="baseInfo" Tab="@Localizer[nameof(EasyJobLocalResource.BasicInformation)]" Closable="false">
                <Row Gutter="24">
                    <GridCol Span="14">
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.TriggerId)]">
                            <Input @bind-Value="@model.TriggerId" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.JobId)]">
                            <Input @bind-Value="@model.JobId" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(SharedLocalResource.Description)]">
                            <TextArea @bind-Value="@model.Description" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.TriggerAssemblyType)]">
                            <RadioGroup TValue="string" @bind-Value="@model.TriggerType" OnChange="OnChangeExecuteType">
                                <Radio Value="@(EasyJobConstant.TriggerTypeInterval)">@Localizer[nameof(EasyJobLocalResource.Interval)]</Radio>
                                <Radio Value="@(EasyJobConstant.TriggerTypeCron)">@Localizer[nameof(SharedLocalResource.Cron)]</Radio>
                            </RadioGroup>
                        </FormItem>
                        @if (EasyJobConstant.TriggerTypeInterval.Equals(model.TriggerType))
                    {
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.Interval)]">
                                <InputNumber @bind-Value="@triggerInterval" />
                            </FormItem>
                    }
                    else if (EasyJobConstant.TriggerTypeCron.Equals(model.TriggerType))
                    {
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.Cron)]">
                                <AntDesign.Input TValue="string" @bind-Value="@triggerCron">
                                    <AddOnAfter>
                                        <Select TItem="string" TItemValue="int" @bind-Value="@cronType" Style="width: auto;">
                                            <SelectOptions>
                                                @foreach(var item in cronFormatTypeMap)
                                            {
                                                <SelectOption TItemValue="int" TItem="string" Value=@item.Key Label=@item.Value />
                                            }
                                            </SelectOptions>
                                        </Select>
                                    </AddOnAfter>
                                </AntDesign.Input>
                            </FormItem>
                    }
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.TriggerArgs)]">
                            <label>@model.Args</label>
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.StartTime)]">
                            <Input @bind-Value="@model.StartTime" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.EndTime)]">
                            <Input @bind-Value="@model.EndTime" />
                        </FormItem>
                    </GridCol>
                    <GridCol Offset="2" Span="8">
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.MaxNumberOfRuns)]">
                            <InputNumber @bind-Value="@model.MaxNumberOfRuns" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.MaxNumberOfErrors)]">
                            <InputNumber @bind-Value="@model.MaxNumberOfErrors" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.NumRetries)]">
                            <InputNumber @bind-Value="@model.NumRetries" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.RetryTimeout)]">
                            <InputNumber @bind-Value="@model.RetryTimeout" />
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.StartNow)]">
                            <Switch @bind-Value="@model.StartNow"></Switch>
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.RunOnceOnStart)]">
                            <Switch @bind-Value="@model.RunOnStart"></Switch>
                        </FormItem>
                        <FormItem Label="@Localizer[nameof(EasyJobLocalResource.ResetOnlyOnce)]">
                            <LabelTemplate>
                                <label for="ResetOnlyOnce">
                                    <Tooltip Title="@Localizer[nameof(EasyJobLocalResource.ResetOnlyOnceTIPS)]">
                                        @Localizer[nameof(EasyJobLocalResource.ResetOnlyOnce)]<Icon Type="question-circle" Theme="outline" />
                                    </Tooltip>
                                </label>
                            </LabelTemplate>
                            <ChildContent>
                                <Switch @bind-Value="@model.ResetOnlyOnce"></Switch>
                            </ChildContent>
                        </FormItem>
                    </GridCol>
                </Row>
            </TabPane>
            <TabPane Key="status" Tab="@Localizer[nameof(EasyJobLocalResource.RunningStatus)]" Closable="false">
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.AssemblyName)]">
                    <lable>@model.AssemblyName</lable>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.TriggerAssemblyType)]">
                    <lable>@model.TriggerType</lable>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.Status)]">
                    <TagPro Text="@model.Status" Localizer="Localizer"></TagPro>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.NumberOfRuns)]">
                    <lable>@model.NumberOfRuns</lable>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.NumberOfErrors)]">
                    <lable>@model.NumberOfErrors</lable>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.LastRunTime)]">
                    <lable>@model.LastRunTime?.ToLocalTime().ToString(ClientConstant.DateTimeFormat)</lable>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.NextRunTime)]">
                    <lable>@model.NextRunTime?.ToLocalTime().ToString(ClientConstant.DateTimeFormat)</lable>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.ElapsedTime)]">
                    <lable>@model.ElapsedTime</lable>
                </FormItem>
                <FormItem Label="@Localizer[nameof(EasyJobLocalResource.Result)]">
                    <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Result"></TextArea>
                </FormItem>
            </TabPane>
        </Tabs>
        <Row Gutter="24">
            <GridCol Offset="6" Span="18">
                <FormItem WrapperCol="new ColLayoutParam { Offset = 4, Span = 20 }">
                    <Space>
                        @if (!OperationDialogInputType.Select.Equals(this.Options.Type))
                    {
                        <SpaceItem>
                                <Button Type="@ButtonType.Primary" HtmlType="submit">
                                    @Localizer[nameof(SharedLocalResource.Save)]
                                </Button>
                            </SpaceItem>
                    }
                        <SpaceItem>
                            <Button OnClick="OnFormCancel">
                                @Localizer[nameof(SharedLocalResource.Cancel)]
                            </Button>
                        </SpaceItem>
                    </Space>
                </FormItem>
            </GridCol>
        </Row>
    </Form>
}